<template>
	<baseDialog ref="dialogRef" :title="dialogTitle" width="680px" :showFooter="false" @close="handleClose">
		<el-descriptions class="w-full" direction="horizontal" :column="1" border>
			<el-descriptions-item class-name="el-descriptions-content-break" label-class-name="w-[120px]" label="队列名称">
				{{ detailData.queue }}
			</el-descriptions-item>
			<el-descriptions-item class-name="el-descriptions-content-break" label-class-name="w-[120px]" label="任务名称">
				{{ detailData.job_name }}
			</el-descriptions-item>
			<el-descriptions-item class-name="el-descriptions-content-break" label-class-name="w-[120px]" label="任务id">
				{{ detailData.job_id }}
			</el-descriptions-item>
			<el-descriptions-item class-name="el-descriptions-content-break" label-class-name="w-[120px]" label="传递参数">
				<span class="break-words w-full">{{ detailData.param }}</span>
			</el-descriptions-item>
			<el-descriptions-item class-name="el-descriptions-content-break" label-class-name="w-[120px]" label="队列驱动">
				{{ detailData.drive }}
			</el-descriptions-item>
			<el-descriptions-item class-name="el-descriptions-content-break" label-class-name="w-[120px]" label="执行耗时">
				{{ detailData.execute_time }} 秒
			</el-descriptions-item>
			<el-descriptions-item class-name="el-descriptions-content-break" label-class-name="w-[120px]" label="重试次数">
				{{ detailData.retry_num }}
			</el-descriptions-item>
			<el-descriptions-item class-name="el-descriptions-content-break" label-class-name="w-[120px]" label="运行结果">
				{{ detailData.result_desc }}
			</el-descriptions-item>
			<el-descriptions-item class-name="el-descriptions-content-break" label-class-name="w-[120px]" label="运行信息">
				{{ detailData.result_msg }}
			</el-descriptions-item>
			<el-descriptions-item class-name="el-descriptions-content-break" label-class-name="w-[120px]" label="创建时间">
				{{ detailData.create_time }}
			</el-descriptions-item>
		</el-descriptions>
	</baseDialog>
</template>

<script setup lang="ts" name="queueLogDetail">
import { ref, computed } from 'vue';
import { queueLogDetail } from '/@/api/setting/system';

const dialogRef = ref(null);

const dialogTitle = computed(() => {
	return '队列日志详情';
});

const emit = defineEmits(['close']);

const detailData = ref(null);

const setFormData = async (row: any, callback: any) => {
	const data = await queueLogDetail({
		id: row.id,
	});

	detailData.value = data;

	callback();
};

const handleClose = () => {
	emit('close');
};

const open = () => {
	dialogRef.value?.open();
};

defineExpose({
	open,
	setFormData,
});
</script>
